<template>
	<!--邀请个人-->
	<view class="page-content">
		<view class="page-top">
			<!--导航-->
			<view class="nav">
				<view class="nav-item" @click="handleActive(1)"
					:class="[active === 1 ? 'active' : active === 2 ? '' : '']">
					公司
				</view>
				<view class="nav-item" @click="handleActive(2)"
					:class="[active === 1 ? '' : active === 2 ? 'active' :'']">
					供应商
				</view>
			</view>
		</view>
		<!--公司-->
		<view class="page-body">
			<!--公司-->
			<view class="body-item" v-if="active=== 1">
				<view class="input-row">
					<view class="input-row-t"><text class="required">*</text>手机号码：</view>
					<input class="input-row-w" type="text" v-model="params.mobile" placeholder="请输入手机号码"
						 placeholder-style="color:#ddd"></input>
				</view>
				<view class="input-row">
					<view class="input-row-t"><text class="required">*</text>昵称：</view>
					<input class="input-row-w" type="text" v-model="params.name" placeholder="请输入用户名称"
						 placeholder-style="color:#ddd"></input>
				</view>
				<view class="input-row">
					<view class="input-row-t">系统小组：</view>
					<view class="row-sel-box" @tap="toggleTab('selectxl')">
						<view class="sel_name" :style="{color:params.groupname==='请选择'?'#ddd':'#333'}">{{params.groupname}}</view>
						<view class="icons icon-gengduo"></view>
					</view>
				</view>
				<view class="box-button" @click="confirm">确认</view>
			</view>
			<!--供应商-->
			<view class="body-item" v-if="active === 2">
				<view class="input-row">
					<view class="input-row-t"><text class="required">*</text>手机号码：</view>
					<input class="input-row-w" type="text" v-model="params2.mobile" placeholder="请输入手机号码"
						 placeholder-style="color:#ddd"></input>
				</view>
				<view class="input-row">
					<view class="input-row-t"><text class="required">*</text>昵称：</view>
					<input class="input-row-w" type="text" v-model="params2.name" placeholder="请输入用户名称"
						 placeholder-style="color:#ddd"></input>
				</view>
				<view class="input-row">
					<view class="input-row-t">供应商：</view>
					<view class="row-sel-box" @tap="toggleTab('selectxl')">
						<view class="sel_name" :style="{color:params2.groupname==='请选择'?'#ddd':'#333'}">{{params2.groupname}}</view>
						<view class="icons icon-gengduo"></view>
					</view>
				</view>
				<view class="switch-row">
					<view class="switch-row-l">是否开启管理功能</view>
					<switch @change="switchChange2" color="#198FFF" style="transform:scale(0.7)" />
				</view>
				<view class="box-button" @click="confirm">确认</view>
			</view>
		</view>
		<w-picker mode="selector" defaultVal="" @confirm="onSelctXL" ref="selectxl" themeColor="#f00"
			:selectList="active===1?label1:label2"></w-picker>
	</view>
</template>

<script>
	import {
		mapMutations,
		mapState
	} from 'vuex'
	import wSelSearch from '@/components/w-sel-logo/w-sel-search.vue'; //搜索
	import wPicker from "@/components/w-picker/w-picker.vue"
	import {
		getgamelists,
		getuserawaitlists, //获取待开赛比赛列表【我的】
	} from '@/common/api.js'
	export default {
		components: {
			wPicker,
			wSelSearch
		},
		data() {
			return {
				active: 1, //tab导航
				lists: [],
				params:{
					mobile:'',
					name:'',
					groupname:'请选择'
				},
				params2:{
					mobile:'',
					name:'',
					groupname:'请选择',
					statu:false
				},
				label1: [{
					label: "公司成员",
					value: 1
				}, {
					label: "设计部",
					value: 2
				}, {
					label: "产品部",
					value: 3
				}, {
					label: "产品部",
					value: 4
				}, {
					label: "产品部",
					value: 5
				}],
				label2: [{
					label: "待分组",
					value: 1
				}, {
					label: "供应商一",
					value: 2
				}, {
					label: "供应商二",
					value: 3
				}]
			}
		},
		computed: {
			...mapState(['hasLogin', 'openid'])
		},
		onShow() {
			this.getdata1(this.formData1);
			this.getdata2(this.formData2);
		},
		onLoad(option) {
			console.log(222, option)
			if (option.active) {
				this.active = parseInt(option.active);
				console.log(3,this.active)
			}
		},
		onNavigationBarButtonTap(e) {
			console.log(123, e)
			if (e.index === 0) {
				console.log(444)
				uni.navigateTo({
					url:`/pages/contact/contactSearch`
				})
			}
		},
		methods: {
			switchChange2(e){
				console.log(123,e)
			},
			toggleTab(str, index) {
				this.selecl_num = index;
				this.$refs[str].show();
			},
			//下拉选择
			onSelctXL(e) {
				console.log(1,e)
				console.log(2,this.active)
				if(this.active === 1){
					this.params.groupname = e.result;
				}else if(this.active === 2){
					this.params2.groupname = e.result;
				}
				 
			},
			confirm(){
				
			},
			todetail(id){
				uni.navigateTo({
					url: `/pages/work/workDetail?id=${id}`
				})
			},
			//跳转指派
			todes(id){
				uni.navigateTo({
					url: `/pages/designate/des_one?id=${id}`
				})
			},
			//重置筛选
			resetFilterData() {

			},
			//确认筛选
			setFilterData() {

			},
			//获取当前比赛数据
			getdata1(formData) {
				console.log(234, formData)
				/* getuserawaitlists(formData).then(res => {
					console.log(123, res)
					this.ld_num = res.count
					let datalist = res.data
					if(datalist && datalist.length>0){
						datalist.forEach(item => {
							this.$set(item, 'image', item.img[0])
						})
						if(this.load_sta){
							if (datalist && datalist.length < 10) {
								this.load_more1 = '没有更多了';
								this.datalist1 = this.datalist1.concat(datalist);
							} else {
								this.load_more1 = '加载中...';
									this.datalist1 = this.datalist1.concat(datalist);
							}
						}else{
							if (datalist && datalist.length < 10) {
								this.load_more1 = '没有更多了';
								this.datalist1 = datalist;
							} else {
								this.load_more1 = '加载中...';
								this.datalist1 = datalist;
							}
						}
					}
				}) */
			},
			//获取往期回顾数据
			getdata2(formData) {
				/* getuserawaitlists(formData).then(res => {
					console.log(123, res)
					this.cy_num = res.count
					let datalist = res.data
					if(datalist && datalist.length>0){
						datalist.forEach(item => {
							this.$set(item, 'image', item.img[0])
						})
						if(this.load_sta){
							if (datalist && datalist.length < 10) {
								this.load_more2 = '没有更多了';
								this.datalist2 = this.datalist2.concat(datalist);
							} else {
								this.load_more2 = '加载中...';
									this.datalist2 = this.datalist2.concat(datalist);
							}
						}else{
							if (datalist && datalist.length < 10) {
								this.load_more2 = '没有更多了';
								this.datalist2 = datalist;
							} else {
								this.load_more2 = '加载中...';
								this.datalist2 = datalist;
							}
						}
					}
				}) */
			},
			change(e) {
				this.current = e.detail.current
			},
			handleActive(e) {
				let _self = this;
				_self.active = e;
			},
			//跳转比赛详情
			clickdet(id) {
				uni.navigateTo({
					url: `/pages/user/entryDetail?id=${id}`
				})
			},
		},
		onPullDownRefresh() {
			console.log('refresh');
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
			/* if (this.$refs.indexPage) {
				this.$refs.indexPage.getData()
				console.log(1231)
			} */
		}
	}
</script>

<style lang="scss">
	.required{
		color: #FE5252;
		font-size: 28rpx;
	}
	.titleNview-placing {
		height: var(--status-bar-height);
		box-sizing: content-box;
		background: $uni-bg-color;
		display: block;
		position: sticky;
		top: 0rpx;
		z-index: 9999;
		overflow: hidden
	}
	.page-content {
		display: flex;
		flex-direction: column;
		height: 100%;

		.page-top {
			display: flex;
			flex-direction: column;
			background: $uni-bg-color-grey;

			.nav {
				height: 88rpx;
				padding: 0 30rpx;
				display: flex;
				align-items: center;
				text-align: center;
				font-size: 32rpx;
				color: $font-color-3;
				font-weight: bold;

				.nav-item {
					flex: 1;
					position: relative;

					&::after {
						content: '';
						width: 0;
						height: 8rpx;
						background-color: $font-color-b3;
						border-radius: 4px;
						position: absolute;
						left: 50%;
						bottom: -18rpx;
						transform: translateX(-50%);
						transition: .3s;
					}

					&.active {
						font-size: 32rpx;
						font-weight: bold;
						color: $font-color-b3;

						&::after {
							width: 36rpx;
						}
					}

					.nav-item-num {
						position: absolute;
						right: 0;
						top: -6rpx;
						width: 32rpx;
						height: 32rpx;
						background: #FF5454;
						border-radius: 50%;
						font-size: 18rpx;
						font-weight: 400;
						line-height: 30rpx;
						color: $font-color-w;
					}
				}
			}
		}

		.page-body {
			height: calc(100% - 170rpx);
			background: $uni-bg-color;
			padding: 0 30rpx;

			.body-item {
				display: flex;
				flex-direction: column;
				height: 100%;
				.box-button{
					margin-top: 60rpx;
					height: 100rpx;
					line-height: 100rpx;
					text-align: center;
					background: $uni-but-bg-color;
					color: $font-color-w;
					box-shadow: 4rpx 8rpx 16rpx rgba(25, 143, 255, 0.25);
					border-radius: 10rpx;
				}
				.switch-row{
					height: 100rpx;
					display: flex;
					justify-content: flex-end;
					align-items: center;
					width: 100%;
					flex-direction: row;
					border-bottom: 1rpx solid #f5f5f5;
					background: $uni-bg-box-color;
					.switch-row-l{
						font-size: 32rpx;
						font-weight: 400;
						color: $font-color-3;
					}
				}

				.input-row {
					height: 100rpx;
					display: flex;
					align-items: center;
					width: 100%;
					flex-direction: row;
					border-bottom: 1rpx solid #f5f5f5;
					background: $uni-bg-box-color;
					.row-sel-box{
						width: 100%;
						flex: 1;
						display: flex;
						align-items: center;
						justify-content: space-between;
						.sel_name{
							font-size: 32rpx;
							font-weight: 400;
						}
						.icons{
							color: $font-color-9;
						}
					}
							
					.input-row-w {
						display: flex;
						flex: 1;
						width: 100%;
						height: 80rpx;
						color: $font-color-3;
						font-size: 28rpx;
						border: 1rpx solid #fff;
					}
					.input-row-t{
						font-size: 32rpx;
						color: #333333;
					}
				}
			}
		}
	}
</style>
